﻿using System;
using System.Collections.Generic;

namespace machines_lib
{
    /// <summary>
    /// Represents a Turing Machine whose transition function is defined by a table
    /// </summary>
    public class TableTuringMachine: TuringMachine
    {
        Dictionary<TMInput, TMOutput> transitionTable;

        public Dictionary<TMInput, TMOutput> TransitionTable
        {
            get { return transitionTable; }
            set { transitionTable = value; }
        }

        public override TMOutput Transition(TMInput x)
        {
            if (TransitionTable.ContainsKey(x))
                return TransitionTable[x];
            else
                throw new KeyNotFoundException();
        }
    }
}
